package testDemo;

import com.cy.spring5.bean.Emp;
import com.cy.spring5.service.UserService;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestBean {

    @Test
    public void testAdd(){
        //加载spring配置文件
        ApplicationContext context =
            new ClassPathXmlApplicationContext("bean2.xml");

        //获取配置创建对象
        UserService userService = context.getBean("userService",UserService.class);

        userService.add();

    }

    @Test
    public void testBean2(){
        //加载spring配置文件
        ApplicationContext context =
                new ClassPathXmlApplicationContext("bean3.xml");

        //获取配置创建对象
        Emp emp = context.getBean("emp", Emp.class);

        emp.add();

    }
}
